#include<bits/stdc++.h>
using namespace std;
#define int long long

//struct node{
//	int yy, 
//};

int a[100005];

signed main(){
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin>>a[i];
	}
	sort(a+1, a+n+1, greater<int>());
	int ans = 0;
	for(int i = 1;i <= n;i++){
		int t = a[i]-i+1;
		if(t <= 0)
			break;
		else
			ans += t;
	}
	cout<<ans;
	return 0;
}
